package com.dfbz.dao;

import com.dfbz.dao.base.BaseDao;
import com.dfbz.model.UserFocus;
import com.dfbz.utils.JDBCUtil;
import org.apache.commons.dbutils.BasicRowProcessor;
import org.apache.commons.dbutils.GenerousBeanProcessor;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.RowProcessor;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

public class UserFocusDao extends BaseDao {

    public UserFocus findFollowData(Integer userId, Integer userFocusId) {
        QueryRunner qr = new QueryRunner(JDBCUtil.getDataSource());
        RowProcessor processor = new BasicRowProcessor(new GenerousBeanProcessor());
        UserFocus focus = null;
        try {
            focus = qr.query("select * from user_focus , where user_id = ? and user_focus_id = ?" , new BeanHandler<>(UserFocus.class, processor) , userId, userFocusId);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return focus;
    }
}
